import simple_protocol as sp

# 创建 SimpleProtocol 实例
protocol = sp.SimpleProtocol([0xA5, 0xA5], 2, 4, True, 128, 200)

data = b"some_data"  # 字节数组
size = len(data)  # 数组长度
extra = 0x12345678  # 额外的 32 位整数
# 调用 pack 函数
packed_data = protocol.pack(data, size)
print(packed_data)


# 使用字符串和额外参数打包
message = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
extra_param = 0x1e30001  # 假设这是你想要传递的额外参数
packed_data = protocol.pack(str(message), extra_param)
print(packed_data)


# 使用字节向量和额外参数打包
data_vector = list([0x05, 0x06, 0x07, 0x08])
extra_param = 123  # 假设这是你想要传递的额外参数
packed_data = protocol.pack(data_vector, extra_param)
print(packed_data)


print(protocol.curr_timestamp_ms())

recv_data =list([165, 165, 29, 45, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 115, 127])
protocol.push_back(recv_data)
protocol.push_back(
    list([165, 165, 12, 9, 115, 111, 109, 101, 95, 100, 97, 116, 97, 249, 87, 78])
)
protocol.push_back(list([165, 165, 7, 123, 5, 6, 7, 8, 157, 6, 12, 43]))
# print("".join(map(str, protocol.parse().data)))
frame = protocol.parse()
print(frame.status, frame.status, frame.str_data())
frame = protocol.parse()
print(frame.status, frame.status, frame.data)
frame = protocol.parse()
print(frame.status, frame.status, frame.data)
frame = protocol.parse()
print(frame.status, frame.status, frame.data)
frame = protocol.parse()
print(frame.status, frame.status, frame.data)
frame = protocol.parse()
print(frame.status, frame.status, frame.data)
frame = protocol.parse()
print(frame.status, frame.status, frame.data)
